package com.only4play.practice.common;

import com.only4play.codegen.support.constants.BaseEnum;
import lombok.Getter;

/**
 *  *
 *  * @Description 状态码定义约束，共6位数，前三位代表服务，后3位代表接口
 *  *  比如 商品服务210,购物车是220、用户服务230，403代表权限
 *  *
 * @author mengdy
 */
@Getter
public enum BizCodeEnum implements BaseEnum<BizCodeEnum> {


    // 返回 0 代表成功
    CODE_SUCCESS(0,"成功"),


    NotFindError(10001, "未查询到信息"),
    SaveError(10002, "保存信息失败"),
    UpdateError(10003, "更新信息失败"),
    ValidateError(10004, "数据检验失败"),
    StatusHasValid(10005, "状态已经被启用"),
    StatusHasInvalid(10006, "状态已经被禁用"),
    SystemError(10007, "系统异常"),
    BusinessError(10008, "业务异常"),
    ParamSetIllegal(10009, "参数设置非法"),
    TransferStatusError(10010, "当前状态不正确，请勿重复提交"),
    NotGrant(10011,"没有操作该功能的权限，请联系管理员"),

    /**
     *验证码
     */
    CODE_TO_ERROR(240001,"接收号码不合规"),
    CODE_LIMITED(240002,"验证码发送过快"),
    CODE_ERROR(240003,"验证码错误"),
    CODE_CAPTCHA_ERROR(240101,"图形验证码错误"),

    /**
     * 账号
     */
    ACCOUNT_REPEAT(250001,"账号已经存在"),
    ACCOUNT_UNREGISTER(250002,"账号不存在"),
    ACCOUNT_PWD_ERROR(250003,"账号或者密码错误"),
    ACCOUNT_UNLOGIN(250004,"账号未登录"),




    /**
     * 订单
     */
    ORDER_CONFIRM_PRICE_FAIL(280002,"创建订单-验价失败"),
    ORDER_CONFIRM_REPEAT(280008,"订单恶意-重复提交"),
    ORDER_CONFIRM_TOKEN_EQUAL_FAIL(280009,"订单令牌缺少"),
    ORDER_CONFIRM_NOT_EXIST(280010,"订单不存在"),

    /**
     * 支付
     */
    PAY_ORDER_FAIL(300101,"创建支付订单失败"),
    PAY_ORDER_CALLBACK_SIGN_FAIL(300102,"支付订单回调验证签失败"),
    PAY_ORDER_CALLBACK_NOT_SUCCESS(300103,"支付回调更新处理失败"),
    PAY_ORDER_NOT_EXIST(300105,"订单不存在"),
    PAY_ORDER_STATE_ERROR(300106,"订单状态不正常"),
    PAY_ORDER_PAY_TIMEOUT(300107,"订单支付超时"),
    PAY_ORDER_PAY_FAIL(300201,"支付业务异常，请稍后重试"),
    PAY_ORDER_REFUND_FAIL(300202,"退款失败"),
    PAY_ORDER_REFUND_TIMEOUT(300203,"退款超时"),
    PAY_ORDER_REFUND_STATE_ERROR(300204,"退款状态不正常"),
    PAY_ORDER_REFUND_NOT_EXIST(300205,"退款订单不存在"),
    PAY_ORDER_REFUND_STATE_ERROR_REFUND(300206,"退款状态不正常"),
    // 回调失败
    PAY_CALLBACK_FAIL(300301,"支付回调处理失败"),


    /**
     * 流控操作
     */
    CONTROL_FLOW(500101,"限流控制"),
    CONTROL_DEGRADE(500201,"降级控制"),
    CONTROL_AUTH(500301,"认证控制"),



    /**
     * 通用操作码
     */

    OPS_REPEAT(110001,"重复操作"),
    OPS_NETWORK_ADDRESS_ERROR(110002,"网络地址错误"),
    OPS_CREATE_ERROR(110003,"创建失败"),
    OPS_UPDATE_ERROR(110004,"更新失败"),


    /**
     * 文件相关
     */
    FILE_UPLOAD_USER_IMG_FAIL(700101,"用户头像文件上传失败"),


    /**
     * 数据库路由信息
     */
    DB_ROUTE_NOT_FOUND(800101,"数据库找不到"),


    /**
     * MQ消费异常
     */
    MQ_CONSUME_EXCEPTION(900101,"消费者消费异常"),


    /**
     * 数据查询条数超过限制
     */
    DATA_OUT_OF_LIMIT_SIZE(400001,"查询条数超过限制") ,

    /**
     * 数据查询超过最大跨度
     */
    DATA_OUT_OF_LIMIT_DATE(400002,"日期查询超过最大跨度") ;


    private String name;

    private int code;

    private BizCodeEnum(int code, String msg){
        this.code = code;
        this.name = msg;
    }


    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getName() {
        return this.name;
    }
}